#include "model/Diagram.h"
#include "model/Utils.h"
#include "model/der/Fork.h"
#include <exception>
#include <math.h>
#include <iostream>
#include <string.h>
#include <list>
#include <vector>
#include <map>
#include <stdexcept>
#include <string>
#include <gtkmm-2.4/gtkmm/messagedialog.h>


Diagram::Diagram(const std::string & name) {
	m_sizeX = m_sizeY = 0;
	m_name = name;
	m_lastAttributeId = 0;
	m_arrow_style = ArrowHead::ARROW_LINE;
}

Diagram::~Diagram(){
	for(unsigned i = 0; i < m_components.size(); i++)
		delete m_components[i];
}

std::string Diagram::getName(){
    return m_name;
}
std::string Diagram::getPath(){
    return m_path;
}

void Diagram::setPath(const std::string & path) {
    m_path = path;
}

int Diagram::getId(Component* component)
{
	for( unsigned i = 0; i < m_components.size(); i++)
		if(m_components[i] == component)
			return i;
	return -1;

}

void Diagram::addComponent(Component* component)
{
	m_components.push_back(component);
	
}

void Diagram::removeComponent(Component* component) {
	for(std::vector<Component*>::iterator it = m_components.begin(); it != m_components.end(); ++it)
		if((*it) == component) {
		   m_components.erase(it);
		   return;
		}
}

std::vector<Component*>* Diagram::getComponents(){
    return &m_components;
}

unsigned Diagram::getSizeX() const{
    return m_sizeX;
}

unsigned Diagram::getSizeY() const{
    return m_sizeY;
}

void Diagram::setSize(unsigned sizeX, unsigned sizeY){
    m_sizeX = sizeX;
    m_sizeY = sizeY;
}

void Diagram::setName(const std::string & name){
    m_name = name;
}

ArrowHead::ArrowStyle Diagram::getArrowStyle() const {
	return m_arrow_style;
}

void Diagram::setArrowStyle(ArrowHead::ArrowStyle arrowStyle) {
	m_arrow_style = arrowStyle;
}
